# Maintainer: David Runge <dvzrv@archlinux.org>

_name=sphinxcontrib-programoutput
pkgname=python-sphinxcontrib-programoutput
pkgver=0.17
pkgrel=4
pkgdesc="Sphinx extension for capturing program output"
arch=(any)
url="https://sphinxcontrib-programoutput.readthedocs.io/en/latest/"
license=(BSD)
depends=(python-sphinx)
makedepends=(python-build python-installer python-setuptools python-wheel)
checkdepends=(python-pytest)
source=(https://files.pythonhosted.org/packages/source/${_name::1}/$_name/$_name-$pkgver.tar.gz)
sha256sums=('300ee9b8caee8355d25cc74b4d1c7efd12e608d2ad165e3141d31e6fbc152b7f')
b2sums=('07687a221aa9be1e02629b2961b49eace217631a1298337f77a01986c3c6444a50069a8a8b9c96ca224895ae0f9490158a720519fdf3fb544e9d3e513282eb36')

build() {
  cd $_name-$pkgver
  python -m build --wheel --no-isolation
}

check() {
  local _site_packages=$(python -c "import site; print(site.getsitepackages()[0])")

  cd $_name-$pkgver
  python -m installer --destdir=test_dir dist/*.whl
  export PYTHONPATH="test_dir/$_site_packages:$PYTHONPATH"

  pytest -vv test_dir/$_site_packages
}

package() {
  cd $_name-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -vDm 644 LICENSE -t "$pkgdir/usr/share/licenses/$pkgname/"
  install -vDm 644 {CHANGES,README}.rst -t "$pkgdir/usr/share/doc/$pkgname/"
}
